package com.tarena.lbs.marketing.mapper;

import com.tarena.lbs.pojo.marketing.dos.UserReceiveCouponDO;
import com.tarena.lbs.pojo.marketing.query.UserCouponQuery;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserReceiveCouponMapper {
    void insert(UserReceiveCouponDO aDo);

    @Select("select * from tarena_lbs_marketing.user_receive_coupon " +
            "where user_id=#{userId} and coupon_id=#{couponId}")
    List<UserReceiveCouponDO> selectReceiveRecordsByUserIdAndCouponId(@Param("userId") Integer userId, @Param("couponId") Integer couponId);

    @Select("select * from tarena_lbs_marketing.user_receive_coupon where user_id=#{userId} and status=#{status}")
    List<UserReceiveCouponDO> selectReceiveRecordsByUserId(UserCouponQuery query);

    @Select("select * from tarena_lbs_marketing.user_receive_coupon where coupon_code=#{code}")
    UserReceiveCouponDO selectReceiveRecordsByCode(String couponCode);
}
